﻿Public Class FrmListeTravaux
    Dim position As Integer
    Dim macnx As New PPE3.ClassMySqlConnect("853339_depanneur", "071064")
    Dim nbchamps As Integer = 0
    Private Sub FrmListeTravaux_FormClosing(sender As Object, e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        'SeConnecter()
        'MonJeuDeDonnees.Tables("ListeTravaux").Clear()
        'MaConnexion.Close()
    End Sub

    Private Sub FrmListeTravaux_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        Me.MdiParent = FrmStart
        macnx.Se_Connecter_MySqlServer()
        macnx.viderVue("allTarif")
        DataGridClient.DataSource = RemplaceSlashApostrophesDataTable(macnx.Executer_Requete_Select("SELECT IdTravauxTarif as NumeroTravaux, NomTravaux, PrixTtc FROM travauxTarif", "allTarif"))
        DataGridClient.AutoResizeColumns()
        macnx.Se_Deconnecter_MySqlServer()
    End Sub

    Public Function RemplaceSlashApostrophesDataTable(ByRef lesdonnees As DataTable)
        Dim nblignes As Integer
        Dim nbcolonnes As Integer
        Dim test As String = ""
        nblignes = lesdonnees.Rows.Count
        nbcolonnes = lesdonnees.Columns.Count
        Dim i, j As Integer
        For i = 0 To nblignes - 1
            For j = 0 To nbcolonnes - 1
                'Attention le replace ne s'applique qu'aux type String : utilisation de la classe de base Object :
                If Object.ReferenceEquals(lesdonnees.Rows(i).Item(j).GetType(), test.GetType()) Then
                    lesdonnees.Rows(i).Item(j) = RemplaceSlashApostrophes(lesdonnees.Rows(i).Item(j))
                End If
            Next
        Next
        Return lesdonnees
    End Function

    Public Function RemplaceApostrophesSlash(ByRef unechaine As String) As String
        Dim ch As String
        ch = unechaine.Replace("'", "/")
        Return ch
    End Function


    Public Function RemplaceSlashApostrophes(ByRef unechaine As String) As String
        Dim ch As String
        ch = unechaine.Replace("/", "'")
        Return ch
    End Function

    Private Sub BtnFermer_Click(sender As System.Object, e As System.EventArgs) Handles BtnFermer.Click
        Close()
    End Sub
End Class